// ignore_for_file: file_names, must_be_immutable

// 无状态组件, 纯展示用的组件
import 'package:flutter/material.dart';

class MyApp16 extends StatelessWidget {
  const MyApp16({super.key});

  List<Widget> getChildren() {
    return [1, 2, 3, 4, 5, 6, 7, 9, 10].map((int value) {
      return Container(
        alignment: Alignment.center,
        color: Colors.teal,
        child: Text(
          '第$value个',
          style: const TextStyle(color: Colors.white, fontSize: 30),
        ),
      );
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        // 1.1 导航
        appBar: AppBar(
          title: const Text('GridView组件'),
          backgroundColor: Colors.pink,
        ),
        // 1.2 主体内容
        body: Padding(
            padding: const EdgeInsets.all(10),
            child: GridView.extent(
              maxCrossAxisExtent: 200,
              crossAxisSpacing: 10,
              mainAxisSpacing: 10,
              children: getChildren(),
            )));
  }
}
